home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / adaed / gwudemos / elevdemo.ada < prev    next >
Encoding:
Text File  |  1996-01-30  |  1.6 KB  |  44 lines

  1.                 
  2. -- Simple Elevator Simulatiion Program
  3. --
  4. -- By Arthur V. Lopes - (C) 1993 - The George Washington University
  5.  
  6. WITH Elevator_Simulation;
  7. WITH Screen_IO;  Use Screen_IO;
  8. WITH Random; USE Random;
  9. WITH Text_IO; USE Text_IO;
  10. PROCEDURE Run_Elevator_System IS
  11.     PACKAGE This_Elevator_System IS NEW Elevator_Simulation
  12.         ( 2  -- Number of Elevators
  13.         , 8  -- Capacity of Each Elevator (No. of Passengers)
  14.         , 9  -- Number of Floors
  15.         ,32  -- Number of Passengers
  16.         );
  17.     USE This_Elevator_System; 
  18. BEGIN
  19.     --ClearScreen;
  20.     IF No_Floors > 9 OR No_Elevators > 6 OR Elevator_Capacity > 9 THEN
  21.         Put_Line("Invalid Elevator_Simulation Generic Instantiation!");
  22.         Put_Line("   First parameter's range is 1..6");
  23.         Put_Line("   Secong parameter's range is 1..9");
  24.         Put_Line("   Third parameter's range is 1..9");
  25.         return;
  26.     END IF;
  27.     Set_Seed(Floor_Type'LAST / 2);
  28.     Terminal.WriteAt(Where => (1,1), What => "                Passengers");
  29.     Terminal.WriteAt(Where => (2,1), What => "At Floor :");
  30.     Terminal.WriteAt(Where => (3,1), What => "Going to :");
  31.     Terminal.WriteAt(Where => (5,1), What => "At Floor :");
  32.     FOR I IN 1..No_Floors LOOP
  33.         Terminal.WriteAt(Where => (5, I * 2 + 14), What => Integer'IMAGE(I));
  34.     END LOOP;
  35.     -- Start Elevators
  36.     Control.Start;
  37.     Control.Open_Doors_Building;    
  38.     Control.Shut_Down;
  39.     Terminal.WriteAt(Where => (1,10), 
  40.                      What => "Average waiting time : " 
  41.                              & Integer'IMAGE (Total_Wait_Time / No_Passengers));
  42. END Run_Elevator_System;
  43.  
  44.